package com.yuyou.weixin.job;


import com.yuyou.weixin.service.ISrsActivityService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * @author ZY
 *
 */
@Component
public class ResBatchScheduled {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Autowired
	private ISrsActivityService srsActivityService ;

	@Value("${active.count}")
	private Integer activeCount;

	// 每隔2秒执行任务
	@Scheduled(cron="0 0/5 * * * ?")
    public void executeFileDownLoadTask(){
		logger.info("job任务开始执行");
		List<Long> list = srsActivityService.findCompletedNoUpdate(activeCount);
		if(!CollectionUtils.isEmpty(list)){
			logger.info("job--任务发现需要更新的助力状态");
			srsActivityService.updateByIds(list);
			logger.info("job--更新任务成功");
		}else{
			logger.info("job--未发现需要执行的数据");
		}
    }
}
